<template>
  <div class="waitao">
    <div class="box">
      <h1>惠泽保险登录</h1>
      <el-form :model="user" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="账号" prop="username">
          <el-input v-model="user.userName"></el-input>
        </el-form-item>

        <el-form-item label="密码" prop="password">
          <el-input v-model="user.password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="login">立即登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>


<script>
// import axios from "axios";
import api from "../../network/apis/api";
export default {
  data() {
    return {
      user: {
        userName: "xiaowang",
        password: "xiaowang",
      },
    };
  },
  methods: {
    async login() {
          const { data } = await api.users.login(this.user);
        //   console.log(data);
          if (data.status) {
          localStorage.token = data.token;
          localStorage.userName = data.loginer.userName;
          localStorage._id = data.loginer._id;
        }
    }
  },
};
</script>

<style >
.box {
  width: 400px;
  height: 300px;
  margin: 100px auto;
}
.waitao {
  width: 600px;
  height: 300px;
  /* background: url('./img/abe1eea3ca79fc28-c577ebdcb0f3dbcc-aea9558e3eacd634f250d740f671de22.jpg'); */
  text-align: center;
  margin: 0px auto;
}
body {
  /* background: url('./img/timg.jpg') no-repeat ; */
  background-size: cover;
}
</style>